import 'package:WebTest/service/http_request.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("dio"),
        ),
        body: HomePage(),
      ),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
////    发送请求
////  1.创建dio
//    final dio = Dio();
////  2.发送网络请求
//    dio.get("https://httpbin.org/get").then((value) {
//      print(value);
//    });
//    dio.post("https://httpbin.org/post").then((value) {
//      print(value);
//    });
    HttpRequest.request("get", params: {"name": "shy"})
        .then((value) {
      print(value);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
